package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@RequiredArgsConstructor
@Getter
public enum UserCategoryEnum {

    /**
     * vip
     */
    VIP("2"),

    /**
     * 普通
     */
    NO_VIP("1");

    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param category
     * @return
     */
    public static UserCategoryEnum acquire(final String category) {
        Optional<UserCategoryEnum> categoryEnum = Arrays.stream(UserCategoryEnum.values())
                .filter(c -> (Objects.equals(c.status, category)))
                .findFirst();
        return categoryEnum.orElse(UserCategoryEnum.NO_VIP);
    }
}
